import http from "@/utils/http";
import type * as ContractConfig from "./type";

/**
 * 合同类型列表
 */
export const contractTypeList = () => {
  return http.get<ContractConfig.ContractTypeList[]>("/contract/template/type/list");
};
/**
 * 新增合同类型
 */
export const addContractType = (data: any) => {
  return http.post("/contract/template/type/crate", data);
};

/**
 * 删除合同类型
 */
export const delContractType = (id: string) => {
  return http.deleteMethod(`/contract/template/type/delete/${id}`);
};

/**
 * 合同类型详情
 */
export const contractTypeDetail = (id: string) => {
  return http.get<ContractConfig.ContractTypeDetail>(`/contract/template/type/detail/${id}`);
};
/**
 * 关联报价模板
 */
export const budgetTemplateList = (id: string) => {
  return http.get<ContractConfig.ContractTypeDetail>(`/contract/template/type/getBudgetTemplateList/${id}`);
};

/**
 * 合同模板
 */
export const contractTemplateList = (params: ContractConfig.ContractTemplateParams) => {
  return http.get<ContractConfig.ContractTemplateItem[]>("/contract/template/list", params);
};

/**
 * 添加关联协议模板
 */
export const addContractTypeProtocol = (id: string, contractTemplateId: string) => {
  return http.post(`/contract/template/type/createProtocol/${id}/${contractTemplateId}`);
};

/**
 * 删除关联协议模板
 */
export const delContractTypeProtocol = (protocolId: string) => {
  return http.deleteMethod(`/contract/template/type/deleteProtocol/${protocolId}`);
};

/**
 * 搜索业务类型
 */
export const searchBusinessType = (params: ContractConfig.SearchBusTypeParams) => {
  return http.get<ContractConfig.SearchBusTypeItem[]>("/contract/template/type/searchReceiveType", params);
};

/**
 * 搜索业务类型下的任务节点
 */
export const searchBusinessTypeTask = (params: ContractConfig.SearchBusTypeTaskParams) => {
  return http.get<ContractConfig.SearchBusTypeTaskItem[]>("/contract/template/type/searchReceiveTypeNode", params);
};

/**
 * 任务节点排序
 */
export const sortBusinessTypeTask = (data: string[]) => {
  return http.put(`/contract/template/type/receiveNodeSort`, data);
};

/**
 * 创建收款计划
 */
export const createPaymentPlan = (data: any) => {
  return http.post("/contract/template/type/cratePlain", data);
};

/**
 * 收款计划详情
 */
export const paymentPlanDetail = (contractTypeId: any) => {
  return http.get(`/contract/template/type/receivePlain/${contractTypeId}`);
};
